package com.example.coroutines

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking

/**
 * @author yaotianxue
 * @description
 * @date 2024/10/17
 */
fun main(){
    // 创建一个协程作用域
    val  scope = CoroutineScope(Dispatchers.Default)
    val result = scope.async {
        delay(2000)
        "hello,world"
    }
    Thread.sleep(3000)
    runBlocking {
        println("result:${result.await()}")
    }
}